package redis;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @Author ZXR
 * @Date 2021/7/1 20:37
 * @Version 1.0
 */

@SpringBootTest
public class test {
    //现在需要保证导入的是我们自己的RedisTemplate
    /*@Autowired
    @Qualifier("redisTemplate") //因为有多个RedisTempalte,底层也有一个，所以通过这种qualifier的方式指定
    private RedisTemplate redisTemplate;

    @Test
    public void test() throws JsonProcessingException {
        //设置的是一个对象
        redisTemplate.opsForValue().set("user","sharon");
        //因为user没有序列化所以jdbcSerializable无法传输
        System.out.println(redisTemplate.opsForValue().get("user"));
    }*/
    @Test
    public void testJiaMi(){
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        System.out.println(passwordEncoder.encode("123456"));
    }
    //测试读取excel
    @Test
    public void readExcel(){
        List<String> huoliNames=new ArrayList<>();
        List<String> gongtong=new ArrayList<>();
        try{
            jxl.Workbook wb =null;
            InputStream is = new FileInputStream("D:\\云计算\\曾老师组\\苦力\\链接找名字\\火力.xls");
            wb = Workbook.getWorkbook(is);
            //这里获取的是这个excel文件有几张sheet表，底下的Sheet1,Sheet2.。。
            int sheetSize = wb.getNumberOfSheets();
            //获取第一张sheet表
            Sheet sheet = wb.getSheet(0);
            //System.out.println(sheet);
            //获取这张表的行数
            int row_total = sheet.getRows();
            for (int j = 0; j < row_total; j++) {

            //获取这张表的第j行的几个单元格
            Cell[] cells = sheet.getRow(j);
            //获取第一个单元格
            huoliNames.add(cells[0].getContents());
            //System.out.println(cells[0].getContents());
//                    System.out.println(cells[1].getContents());
//                    System.out.println(cells[2].getContents());
            }

            jxl.Workbook wb2 =null;
            InputStream is2 = new FileInputStream("D:\\云计算\\曾老师组\\苦力\\链接找名字\\高性能计算.xls");
            wb2 = Workbook.getWorkbook(is2);
            //这里获取的是这个excel文件有几张sheet表，底下的Sheet1,Sheet2.。。
            int sheetSize2 = wb2.getNumberOfSheets();
            //获取第一张sheet表
            Sheet sheet2 = wb2.getSheet(0);
            //获取这张表的行数
            int row_total2 = sheet2.getRows();
            for (int j = 0; j < row_total2; j++) {

                //获取这张表的第j行的几个单元格
                Cell[] cells = sheet2.getRow(j);
                //获取第一个单元格
                if(huoliNames.contains(cells[0].getContents()))
                    gongtong.add(cells[0].getContents());

//                    System.out.println(cells[1].getContents());
//                    System.out.println(cells[2].getContents());
            }
        }catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        for(String name:gongtong){
            System.out.println(name);
        }
    }
}
